package com.dindang.propertyfee.mvp.ui.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;
import android.widget.TextView;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;

import com.dindang.propertyfee.di.component.DaggerPaymentDetailsComponent;
import com.dindang.propertyfee.di.module.PaymentDetailsModule;
import com.dindang.propertyfee.mvp.contract.PaymentDetailsContract;
import com.dindang.propertyfee.mvp.presenter.PaymentDetailsPresenter;

import com.dindang.propertyfee.R;
import com.telpo.tps550.api.printer.UsbThermalPrinter;


import static com.jess.arms.utils.Preconditions.checkNotNull;

@Route(path = "/propertyfee/activity/PaymentDetailsActivity")
public class PaymentDetailsActivity extends BaseActivity<PaymentDetailsPresenter> implements PaymentDetailsContract.View {

    ImageView mIvBack;
    TextView mTvTitle;
    TextView mTvTotalPrice;

    TextView mTvNumber;
    TextView mTvData;
    TextView mTvAddress;
    TextView mTvName;
    TextView mTvPayPeople;
    TextView mTvPayType;

    RecyclerView mListview;
    TextView mTvTotalPrice2;
    TextView mTvCommit;

    UsbThermalPrinter mUsbThermalPrinter = new UsbThermalPrinter(PaymentDetailsActivity.this);

    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerPaymentDetailsComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .paymentDetailsModule(new PaymentDetailsModule(this))
                .build()
                .inject(this);
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.propertyfee_activity_payment_details; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        mIvBack = findViewById(R.id.propertyfee_iv_back);
        mTvTitle = findViewById(R.id.propertyfee_tv_title);
        mTvTotalPrice = findViewById(R.id.propertyfee_tv_total_price);
        mTvNumber = findViewById(R.id.propertyfee_tv_number);
        mTvData = findViewById(R.id.propertyfee_tv_data);
        mTvAddress = findViewById(R.id.propertyfee_tv_address);
        mTvName = findViewById(R.id.propertyfee_tv_name);
        mTvPayPeople = findViewById(R.id.propertyfee_tv_pay_people);
        mTvPayType = findViewById(R.id.propertyfee_tv_pay_type);
        mListview = findViewById(R.id.propertyfee_listview);
        mTvTotalPrice2 = findViewById(R.id.propertyfee_tv_total_price2);
        mTvCommit = findViewById(R.id.propertyfee_tv_commit);

        mTvTitle.setText("收款详情");
        mIvBack.setOnClickListener(v -> mPresenter.finish());
        mPresenter.init();
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }

    @Override
    public TextView getTvTitle() {
        return mTvTitle;
    }

    @Override
    public TextView getTvTotalPrice() {
        return mTvTotalPrice;
    }

    @Override
    public TextView getTvNumber() {
        return mTvNumber;
    }

    @Override
    public TextView getTvData() {
        return mTvData;
    }

    @Override
    public TextView getTvAddress() {
        return mTvAddress;
    }

    @Override
    public TextView getTvName() {
        return mTvName;
    }

    @Override
    public TextView getTvPayPeople() {
        return mTvPayPeople;
    }

    @Override
    public TextView getTvPayType() {
        return mTvPayType;
    }

    @Override
    public RecyclerView getListview() {
        return mListview;
    }

    @Override
    public TextView getTvTotalPrice2() {
        return mTvTotalPrice2;
    }

    @Override
    public TextView getTvCommit() {
        return mTvCommit;
    }

    @Override
    public UsbThermalPrinter getUsbThermalPrinter() {
        return mUsbThermalPrinter;
    }

    @Override
    public BaseActivity getActivity() {
        return this;
    }

    @Override
    public void onBackPressed() {
        mPresenter.finish();
    }

    @Override
    protected void onResume() {
        super.onResume();
    }

    @Override
    protected void onStart() {
        super.onStart();
    }

    @Override
    protected void onStop() {
        mPresenter.onStop();
        super.onStop();
    }
}
